// components/add_select/add_select.js
var app = getApp()
Component({
  /**
   * 组件的属性列表
   */
  properties: {

  },

  /**
   * 组件的初始数据
   */
  data: {
    date1: "",
    date2: "",
    share: []
  },

  /**
   * 组件的方法列表
   */
  methods: {
    getShare() {////////////去数据库中请求
      var that = this
      //console.log(app.globalData.access_token)
      //console.log(app.globalData.openid)
      qq.request({
        url: 'https://api.weixin.qq.com/tcb/databasequery?access_token=' + app.globalData.access_token,
        header: {
          'content-type': 'application/json' // 默认值
        }, method: "post",
        data: {
          "env": "test1-9ws6e",//环境1中的
          "query": "db.collection(\"share\").where({_id:\"1\"}).get()"
        },
        success(res) {
          //console.log(res)
          if (res.data.data.length != 0) {
            //console.log(JSON.parse(res.data.data))

            that.setData({
              share:JSON.parse(res.data.data).share
            })
            //console.log(that.data)
          } else {
            //console.log(res.data.data)
          }
        }
      })
    },
  },
  attached() {
    var week = ["日", "一", "二", "三", "四", "五", "六"]
    var date1 = new Date().getUTCFullYear() + "-" + (new Date().getMonth() + 1) + "-" + new Date().getDate()
    var date2 = "星期" + week[new Date().getDay()]
    this.setData({
      date1: date1,
      date2: date2
    })
    this.getShare()
  },


})
